//
//  BottomNavBar.m
//  GPUImage_MyDemo
//
//  Created by yuedongkui on 2018/5/21.
//  Copyright © 2018年 LY. All rights reserved.
//

#import "BottomNavBar.h"

@implementation BottomNavBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor orangeColor];
        
        CGSize buttonSize = CGSizeMake(28, 28);
        
        self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.backButton setImage:[UIImage imageNamed:@"meitu_embellish_beauty_icon_cancel"] forState:UIControlStateNormal];
        [self addSubview:self.backButton];
        [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(self);
            make.size.mas_offset(buttonSize);
        }];
        
        self.confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.confirmButton setImage:[UIImage imageNamed:@"meitu_embellish_beauty_icon_confirm"] forState:UIControlStateNormal];
        [self addSubview:self.confirmButton];
        [self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.equalTo(self);
            make.size.mas_offset(buttonSize);
        }];
        
        [self.backButton addTarget:self action:@selector(backButtonTap:) forControlEvents:UIControlEventTouchUpInside];
        [self.confirmButton addTarget:self action:@selector(confirmButtonTap:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

#pragma mark - Buttons Events
- (void)backButtonTap:(UIButton *)button
{
    if ([self.delegate respondsToSelector:@selector(bottomNavBarDidBack:)]) {
        [self.delegate bottomNavBarDidBack:self];
    }
}

- (void)confirmButtonTap:(UIButton *)button
{
    if ([self.delegate respondsToSelector:@selector(bottomNavBarDidConfirm:)]) {
        [self.delegate bottomNavBarDidConfirm:self];
    }
}

@end


